<?php
/*
 * Created on 2014-3-19
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
 function st_set_weight($db,$params){
// 	var_dump($params);die;
	include_once dirname(dirname(dirname(__FILE__))).'/op/op_queue.class.php';
	
	$len=count($params['data']);
	$re=array();
	if ($len>0){
		$queue_inst=new op_queue();
		foreach ($params['data'] as $item){
			$p=array();
			$p['org_id']=$params['sp_id'];
			$p['type']=BK_OP_VIDEO;
			$p['ex_id']=$item['id'];
			$p['weight']=$params['weight'];
			$state=$queue_inst->update_weight($db,$p,FALSE);
			if ($state===TRUE){
				$state=0;
			}elseif ($state===FALSE){
				$state=1;
			}
			
			$re[]=array(
				'state'=>$state,
				'id'=>$item['id'],
				'name'=>$item['name'],
			);
			unset($p);
		}
	}
	return $re;
	
 }
?>
